﻿@page "/comic/book/list"

@using HentaiBlazor.Data.Comic
@using HentaiBlazor.Ezcomp

<PageContainer Title="漫画管理">

    <Space Style="float: right;">
        <SpaceItem>
            <SortableList Sortable="@Sortable" OnSort="() => Search()" />
        </SpaceItem>
    </Space>

    <Space Style="margin-bottom: 0.5rem">
        <SpaceItem>
            <Input Prefix="@_filter" Placeholder="关键字" Style="width: 12rem;"
                   @bind-Value="searchKeyword" />
        </SpaceItem>
        <SpaceItem>
            <Input Prefix="@_folder" Placeholder="目录" Style="width: 12rem;"
                   @bind-Value="searchCatalog" />
        </SpaceItem>
        <SpaceItem>
            <Input Prefix="@_team" Placeholder="作者" Style="width: 12rem;"
                   @bind-Value="searchAuthor" />
        </SpaceItem>
        <SpaceItem>
            <RadioGroup @bind-Value="searchFavorite" TValue="bool">
                <Radio RadioButton Value="@(false)">全部</Radio>
                <Radio RadioButton Value="@(true)">收藏</Radio>
            </RadioGroup>
        </SpaceItem>
        <SpaceItem>
            <Button Type="@ButtonType.Primary" OnClick="()=>Search()">查询</Button>
        </SpaceItem>
    </Space>

    <Table TItem="CBookEntity" DataSource="@CBookEntities" Size=@TableSize.Small>
        <ActionColumn Width="160">
            <Space>
                <SpaceItem>
                    <Button Type="@ButtonType.Primary" Danger OnClick="() => OpenRemove(context.Id)">删除</Button>
                    <Button Type="@ButtonType.Primary" OnClick="() => OpenEdit(context.Id)">修改</Button>
                </SpaceItem>
            </Space>
        </ActionColumn>
        <Column Title="最爱" Width="60" @bind-Field="@context.Favorite">
            <IconFavorite Favorite="context.Favorite" />
        </Column>
        <Column Title="标题" @bind-Field="@context.Title">
            <Tooltip Placement="@Placement.TopLeft" Title="@context.Name">
                <a href="@("comic/viewer/" + context.Id)" target="_blank">
                    @context.Title
                </a>
            </Tooltip>
        </Column>
        <Column Title="作者" @bind-Field="@context.Author"></Column>
        <Column Title="语言" @bind-Field="@context.Language">
            <TextLanguage Language="@context.Language" />
        </Column>
        <Column Title="目录" @bind-Field="@context.Path"></Column>
        <Column Title="大小" @bind-Field="@context.Length">
            <TextFileLength FileLength="@context.Length" />
        </Column>
    </Table>
</PageContainer>

@code 
{
    RenderFragment _folder =@<Icon Type="folder" />;
    RenderFragment _team =@<Icon Type="team" />;
    RenderFragment _filter =@<Icon Type="filter" />;
} 